package com.common.springbootcommonmessage.vo;

import com.common.springbootcommonmessage.model.CommonAutopartNotification;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author korol *
 * @date 2022年12月08日 15:36
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class NotificationVo implements Serializable {
    private Integer id;

    private Integer orderID;

    private Integer notificationNo = 1;

    private Integer notificationType = 0;

    private Date createTime;

    private String creator;

    private Date lastUpdateTime;

    private String lastOperator;

    private Integer status = 0;

    private String closeAdmin = "";

    private Boolean allRead = false;

    private Integer partsAvailability = 0;

    private Boolean isNew = true;

    private Integer notificationTemplateID;

    private Integer invoiceID;

    private Integer notificationClass = 0;

    private Integer notificationGroupNo = 1;

    private Boolean isGroupFirst = true;

    private Boolean isSelectAdditionalCharge;

    private Integer rmaID = 0;

    private Integer fixClose = 0;

    private Integer ticketID;


    private Boolean isSendEmail = false;

    private Boolean isSendToCustomer = false;

    private Boolean hasConfirmMessage = false;

    private String confirmMessage;

    /**
     * 数据库对象转换为VO对象
     */
    public static NotificationVo transferToVo(CommonAutopartNotification notification) {

        NotificationVo retVo = null;

        if (notification != null) {
            retVo = new NotificationVo();
            BeanUtils.copyProperties(notification, retVo);
        }
        return retVo;
    }

    /**
     * 数据库对象转换为VO列表对象
     */
    public static List<NotificationVo> transferToVoList(List<CommonAutopartNotification> notificationList) {

        List<NotificationVo> retVoList = null;

        if (notificationList != null && notificationList.size() > 0) {
            retVoList = new ArrayList<NotificationVo>();
            for (CommonAutopartNotification notification : notificationList) {
                NotificationVo retVo = transferToVo(notification);
                if (retVo != null) retVoList.add(retVo);
            }
        }
        return retVoList;
    }

}
